package com.cly.controller;

import com.cly.result.JsonRequest;
import com.cly.service.IPostStatisticsService;
import com.cly.statistics.LineStatistics;
import com.cly.statistics.PieStatistics;
import com.cly.statistics.SumStatistics;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 岗位统计
 *
 * @author by 春风能解释
 * <p>
 * 2025/2/6
 */
@RestController
@RequestMapping("/postChats")
@RequiredArgsConstructor
@Tag(name = "岗位统计控制类", description = "岗位统计操作访问接口")
public class PostStatisticsController {
    /**
     * 岗位统计服务
     */
    private final IPostStatisticsService postStatisticsService;

    /**
     * 岗位30天趋势统计
     *
     * @return JSON
     */
    @GetMapping("/trend")
    @Operation(summary = "岗位30天趋势统计")
    public JsonRequest<LineStatistics<String, Long>> statisticsTrend() {
        return postStatisticsService.statisticsTrend();
    }

    /**
     * 岗位总数统计
     *
     * @return JSON
     */
    @GetMapping("/sum")
    @Operation(summary = "岗位总数统计")
    public JsonRequest<List<SumStatistics<Long>>> sumStatisticsPost() {
        return postStatisticsService.sumStatisticsPost();
    }

    /**
     * 岗位地区统计
     *
     * @return JSON
     */
    @GetMapping("/pie")
    @Operation(summary = "岗位地区统计")
    public JsonRequest<List<PieStatistics<Long>>> postStatisticsDistrict() {
        return postStatisticsService.postStatisticsDistrict();
    }
}
